package com.neuedu.helloworld.controller;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 给所有的Controller 织入 了一段异常处理器
 */
@RestControllerAdvice
//@ControllerAdvice
public class MyControllerException {




    @ExceptionHandler(value = Exception.class )
    String resolveException(HttpServletRequest request, HttpServletResponse response, Exception ex  ){

        System.out.println(ex.getMessage());
        return "{status:'unup',msg:'出错了2'}";
    }


}
